cc.Class({
    extends: cc.Component,
	
	getIndex(index){
		return 70*(index-1);
	},
	
	getMapPointFrame(game){
		return this.getSprite(266,367,90,80,game.resource1);
	},
	
	getHummerFrame(game){
		return this.getSprite(828,667,65,70,game.resource3);
	},
	
	getMagicFrame(game){
		return this.getSprite(91,45,65,70,game.resource3);
	},
	
	getIceFrame(game){
		return this.getSprite(489,746,90,80,game.resource1);
	},
	
	getSignFrame(game){
		return this.getSprite(131,106,30,20,game.resource1);
	},
	
	getMaskFrame(game){
		return this.getSprite(19.5,25,90,80,game.resource1);
	},
	
	
	getBlockPointFrameArr(game){
		return [
									[
								   this.getSprite(this.getIndex(3),this.getIndex(3),70,70,game.resource4),
								   this.getSprite(this.getIndex(3),this.getIndex(3),70,70,game.resource4),
								   this.getSprite(this.getIndex(4),this.getIndex(1),70,70,game.resource4),//竖线
								   this.getSprite(this.getIndex(4),this.getIndex(3),70,70,game.resource4),//右斜
								   this.getSprite(this.getIndex(4),this.getIndex(2),70,70,game.resource4),//左斜
								   this.getSprite(this.getIndex(5),this.getIndex(3),70,70,game.resource4),//三角形
								   this.getSprite(this.getIndex(5),this.getIndex(2),70,70,game.resource4),//花
								   this.getSprite(this.getIndex(5),this.getIndex(1),70,70,game.resource4),//五角星
								   this.getSprite(this.getIndex(1),this.getIndex(1),70,70,game.resource4),//彩色
								   ],//red
								   [
								   this.getSprite(this.getIndex(13),this.getIndex(1),70,70,game.resource4),
								   this.getSprite(this.getIndex(13),this.getIndex(1),70,70,game.resource4),
								   this.getSprite(this.getIndex(13),this.getIndex(2),70,70,game.resource4),//竖线
								   this.getSprite(this.getIndex(14),this.getIndex(1),70,70,game.resource4),//右斜
								   this.getSprite(this.getIndex(13),this.getIndex(3),70,70,game.resource4),//左斜
								   this.getSprite(this.getIndex(15),this.getIndex(1),70,70,game.resource4),//三角形
								   this.getSprite(this.getIndex(14),this.getIndex(3),70,70,game.resource4),//花
								   this.getSprite(this.getIndex(14),this.getIndex(2),70,70,game.resource4),//五角星
								   this.getSprite(this.getIndex(1),this.getIndex(1),70,70,game.resource4),//彩色
								   ],//duck
								   [
								   this.getSprite(this.getIndex(8),this.getIndex(2),70,70,game.resource4),
								   this.getSprite(this.getIndex(8),this.getIndex(2),70,70,game.resource4),
								   this.getSprite(this.getIndex(8),this.getIndex(3),70,70,game.resource4),//竖线
								   this.getSprite(this.getIndex(9),this.getIndex(2),70,70,game.resource4),//右斜
								   this.getSprite(this.getIndex(9),this.getIndex(1),70,70,game.resource4),//左斜
								   this.getSprite(this.getIndex(10),this.getIndex(2),70,70,game.resource4),//三角形
								   this.getSprite(this.getIndex(10),this.getIndex(1),70,70,game.resource4),//花
								   this.getSprite(this.getIndex(9),this.getIndex(3),70,70,game.resource4),//五角星
								   this.getSprite(this.getIndex(1),this.getIndex(1),70,70,game.resource4),//彩色
								   ],//cat
								   [
								   this.getSprite(this.getIndex(6),this.getIndex(1),70,70,game.resource4),
								   this.getSprite(this.getIndex(6),this.getIndex(1),70,70,game.resource4),
								   this.getSprite(this.getIndex(6),this.getIndex(2),70,70,game.resource4),//竖线
								   this.getSprite(this.getIndex(7),this.getIndex(1),70,70,game.resource4),//右斜
								   this.getSprite(this.getIndex(6),this.getIndex(3),70,70,game.resource4),//左斜
								   this.getSprite(this.getIndex(8),this.getIndex(1),70,70,game.resource4),//三角形
								   this.getSprite(this.getIndex(7),this.getIndex(3),70,70,game.resource4),//花
								   this.getSprite(this.getIndex(7),this.getIndex(2),70,70,game.resource4),//五角星
								   this.getSprite(this.getIndex(1),this.getIndex(1),70,70,game.resource4),//彩色
								   ],//bear
								   [
								   this.getSprite(this.getIndex(10),this.getIndex(3),70,70,game.resource4),
								   this.getSprite(this.getIndex(10),this.getIndex(3),70,70,game.resource4),
								   this.getSprite(this.getIndex(11),this.getIndex(1),70,70,game.resource4),//竖线
								   this.getSprite(this.getIndex(11),this.getIndex(3),70,70,game.resource4),//右斜
								   this.getSprite(this.getIndex(11),this.getIndex(2),70,70,game.resource4),//左斜
								   this.getSprite(this.getIndex(12),this.getIndex(3),70,70,game.resource4),//三角形
								   this.getSprite(this.getIndex(12),this.getIndex(2),70,70,game.resource4),//花
								   this.getSprite(this.getIndex(12),this.getIndex(1),70,70,game.resource4),//五角星
								   this.getSprite(this.getIndex(1),this.getIndex(1),70,70,game.resource4),//彩色
								   ],//frog
								   [
								   this.getSprite(this.getIndex(1),this.getIndex(2),70,70,game.resource4),
								   this.getSprite(this.getIndex(1),this.getIndex(2),70,70,game.resource4),
								   this.getSprite(this.getIndex(1),this.getIndex(3),70,70,game.resource4),//竖线
								   this.getSprite(this.getIndex(2),this.getIndex(2),70,70,game.resource4),//右斜
								   this.getSprite(this.getIndex(2),this.getIndex(1),70,70,game.resource4),//左斜
								   this.getSprite(this.getIndex(3),this.getIndex(2),70,70,game.resource4),//三角形
								   this.getSprite(this.getIndex(3),this.getIndex(1),70,70,game.resource4),//花
								   this.getSprite(this.getIndex(2),this.getIndex(3),70,70,game.resource4),//五角星
								   this.getSprite(this.getIndex(1),this.getIndex(1),70,70,game.resource4),//彩色
								   ],//white
								   [
								   this.getSprite(this.getIndex(15),this.getIndex(2),70,70,game.resource4),
								   this.getSprite(this.getIndex(15),this.getIndex(2),70,70,game.resource4),
								   this.getSprite(this.getIndex(15),this.getIndex(3),70,70,game.resource4),//竖线
								   this.getSprite(this.getIndex(16),this.getIndex(2),70,70,game.resource4),//右斜
								   this.getSprite(this.getIndex(16),this.getIndex(1),70,70,game.resource4),//左斜
								   this.getSprite(this.getIndex(17),this.getIndex(2),70,70,game.resource4),//三角形
								   this.getSprite(this.getIndex(17),this.getIndex(1),70,70,game.resource4),//花
								   this.getSprite(this.getIndex(16),this.getIndex(3),70,70,game.resource4),//五角星
								   this.getSprite(this.getIndex(1),this.getIndex(1),70,70,game.resource4),//彩色
								   ],//rabbit
								   
								   [
										this.getSprite(675,740,76,75,game.resource3),//钥匙
										this.getSprite(680,655,76,75,game.resource3),//鞋子
										this.getMagicFrame(game),//魔法棒
										this.getHummerFrame(game)//锤
								   ]//item
								   ];
	},
	
	
	createBoomFrame(game){
		
		if(!this.boomAnimateFrameArr){
		
			this.boomAnimateFrameArr = [
										this.getSprite(210,1848,220,200,game.resource2),
										this.getSprite(430,1848,220,200,game.resource2),
										this.getSprite(650,1848,220,200,game.resource2),
										this.getSprite(870,1848,220,200,game.resource2),
										this.getSprite(1090,1848,220,200,game.resource2)
									];
		
			this.boomclip = cc.AnimationClip.createWithSpriteFrames(this.boomAnimateFrameArr, 5);
 
			this.boomclip.name = 'anim_boom';
		}
	},
	

    createBoomNode(x,y,game){
		
		this.createBoomFrame(game);
		
		var nodeTest = new cc.Node();
 
		var sprite = nodeTest.addComponent(cc.Sprite);
 
		sprite.spriteFrame = this.boomAnimateFrameArr[0];
 
		var animation = nodeTest.addComponent(cc.Animation);
 
		animation.addClip(this.boomclip);
 
		animation.play('anim_boom');
		
		nodeTest.setScale(0.4);
		
		var nodeV = game.node.convertToNodeSpaceAR(cc.v2(x,y));
		
		nodeTest.setPosition(nodeV.x,nodeV.y);
		
		game.effectTop.addChild(nodeTest);
		
		//nodeTest.runAction(cc.scaleTo(0.3));
		
		return nodeTest;
		
	},
	
	createNode(x,y,mapframe,scale,game){//新建节点
		var node = new cc.Node();
		var sprite = node.addComponent(cc.Sprite);
		sprite.spriteFrame = mapframe;
		var nodeV = game.node.convertToNodeSpaceAR(cc.v2(x,y));
		node.setPosition(nodeV.x,nodeV.y);
		node.setScale(scale);
		game.node.addChild(node);
		
		return node;
	},
	
	// 获取贴图
    getSprite(x,y,width,height,resource){
        var sprite = resource.clone(); // 克隆一张图片
        var tmpRect = new cc.Rect(x,y,width,height);
        sprite.setRect(tmpRect);   // 设置 SpriteFrame 的纹理矩形区域
        return sprite;
    }
});
